/*
 * Copyright 1999-2021 Alibaba Group Holding Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.alibaba.llvm4jni.simdjson.stdcxx;

import com.alibaba.fastffi.CXXHead;
import com.alibaba.fastffi.CXXValue;
import com.alibaba.fastffi.FFIFactory;
import com.alibaba.fastffi.FFIGen;
import com.alibaba.fastffi.FFIPointer;
import com.alibaba.fastffi.FFIStringProvider;
import com.alibaba.fastffi.FFITypeAlias;
import com.alibaba.fastffi.FFITypeFactory;

@FFIGen
@FFITypeAlias("std::string_view")
@CXXHead(system = "string_view")
public interface StringView extends FFIPointer, FFIStringProvider {

    static StringView create(String str) {
        return Factory.factory.create(StdString.create(str).c_str());
    }

    static StringView create(StdString stdString) {
        return Factory.factory.create(stdString.c_str());
    }

    @FFIFactory
    interface Factory {
        Factory factory = FFITypeFactory.getFactory(StringView.class);
        @CXXValue StringView create(@FFITypeAlias("char*") long cchar);
    }
    long data();
    long size();
}
